﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WastedMechanics
{
    public class TalkText
    {
        public string Text;
        public string SoundFile;
        public float Duration;
        public SoundEffect Voice;
        
        public TalkText(string text, string soundFile, float duration=0.2f)
        {
            Text = text;
            Duration = duration;
            SoundFile = soundFile;            
        }

        public void LoadVoice()
        {
            if (SoundFile != "")
            {
                Voice = new SoundEffect(SoundFile, false);
                Voice.Load();
                uint durMs = 0;
                Voice.FmodSound.getLength(ref durMs, FMOD.TIMEUNIT.MS);
                Duration = (float)(durMs) / 1000.0f + 0.4f;
            }
        }

        public TalkText(string text, float duration=0.2f) 
            : this(text, "", duration)
        { 
        }
    }
}
